package interview.net.socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

/**
 * @Author: Jun
 * @Date: 2018/9/8 20:19
 */
public class client {
    private Socket socket;
    private BufferedReader br;
    private PrintWriter pw;

    public client() {
        try {
            socket=new Socket("localhost",8888);
            if(socket!=null){
                System.out.println("connect success");
            }
            br=new BufferedReader(new InputStreamReader(System.in));
            pw=new PrintWriter(socket.getOutputStream(),true);
            pw.println(br.readLine());
            socket.close();
            br.close();
            pw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new client();
    }
}
